package homework.ch11_13.p4;

abstract public class Component {
    protected int id;
    protected String name;
    protected double price;

    public Component() {
    }

    public Component(int id, String name, double price) {
        this.id = id;
        this.name = name;
        this.price = price;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public abstract void add(Component component) throws UnsupportedOperationException;

    public abstract double calcPrice();

    public boolean equals(Object obj){

        if(this.id==((Component)obj).id)
            return true;
        else return false;
    }

    public abstract Iterator iterator();

    abstract void remove(Component component)throws UnsupportedOperationException;

    public String toString(){
        StringBuffer s=new StringBuffer();
        s.append("id: "+this.id+", name:"+this.name+", price:"+this.price);

        return s.toString();
    }

}
